﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DirectoryDiffer
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 2) {
                Console.WriteLine("two arguments required");
                return;
            }

            DirectoryInfo seeds = new DirectoryInfo(args[0]);
            DirectoryInfo movies = new DirectoryInfo(args[1]);

            FileInfo[] seedFiles = seeds.GetFiles();
            FileInfo[] movieFiles = movies.GetFiles();

            Console.WriteLine("{0} movies files", movieFiles.Length);
            int unmatched = 0;
            int seedFilesNo = 0;
            foreach (FileInfo seed in seedFiles) {
                bool ismatched = false;
                if (seed.Extension == ".txt")
                    continue;
                seedFilesNo++;
                foreach (FileInfo movie in movieFiles) {
                    string seedName = seed.Name.Substring(0, seed.Name.IndexOf("."));
                    string movieName = movie.Name.Substring(0, movie.Name.IndexOf("."));
                    if (seedName == movieName)
                    {
                        ismatched = true;
                        break;
                    }
                        
                }

                if (!ismatched) {
                    unmatched++;
                    string destiFileName = @"\\hjfyyy-pc\h$\ftproot\sed\";
                    destiFileName += seed.Name;
                    Console.WriteLine(seed.Name);
                    seed.CopyTo(destiFileName, true);
                }
            }
            Console.WriteLine("{0} seed files", seedFilesNo);
            Console.WriteLine("Total unmatched: {0}", unmatched);
        }

    }
}
